//
// Created by 33145 on 2023/6/2.
//

#ifndef ROCKET_TCP_ACCEPTOR_H
#define ROCKET_TCP_ACCEPTOR_H

#include <memory>
#include "net_addr.h"

namespace rocket {

  class TCPAcceptor {  // 封装一下accept
  public:
    typedef std::shared_ptr<TCPAcceptor> ptr;

    TCPAcceptor(const NetAddr::ptr& local_addr);
    ~TCPAcceptor() = default;

    std::pair<int, NetAddr::ptr > accept() const;
    [[nodiscard]] int getListenFd() const;

  private:
    NetAddr::ptr _local_addr;

    int _listen_fd {-1};
    int _family {-1};
  };

}

#endif //ROCKET_TCP_ACCEPTOR_H
